package com.molin.setTest.treeSetTest;
                                //实现泛型接口
public class Student implements Comparable<Student>{
    private String name;
    private int chinese;
    private int math;
    private int englist;

    public Student(String name, int chinese, int math, int englist) {
        this.name = name;
        this.chinese = chinese;
        this.math = math;
        this.englist = englist;
    }

    public Student() {
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", chinese=" + chinese +
                ", math=" + math +
                ", englist=" + englist +
                '}'+getSum();
    }

    private int getSum() {
    return chinese+math+englist;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglist() {
        return englist;
    }

    public void setEnglist(int englist) {
        this.englist = englist;
    }



    @Override
    public int compareTo(Student o) {
        //主要判断
        int result=o.getSum()-this.getSum();
        //次要判断
        result=result==0?o.chinese-this.chinese:result;
        result=result==0?o.math-this.math:result;
        result=result==0?o.englist-this.englist:result;
        result=result==0?this.getName().compareTo(o.getName()):result;
        //逆序，从大到小排
        return  result;
    }
}
